

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/fee")
public class fee extends HttpServlet {
	private static final long serialVersionUID = 1L;
     public fee() throws ClassNotFoundException {
        super();
        Class.forName ("org.sqlite.JDBC");

     }
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	try {
		Connection conn = DriverManager.getConnection("jdbc:sqlite:cms.db");
		String name="bcsf11a001";
		PreparedStatement preStatement = conn.prepareStatement("select total,installement ,payable,paid,due,paiddate from fee where roll= ?");
	    String s="<table  cellspacing=\"1\" cellpadding=\"5\" border=\"1\" style=\"width:100%;\"><tbody><tr class=\"gvHeader\" align=\"center\" valign=\"middle\"><th valign=\"top\" scope=\"col\">Total</th><th valign=\"top\" scope=\"col\">Installements</th><th valign=\"top\" scope=\"col\">Payable</th><th valign=\"top\" scope=\"col\">Paid</th><th valign=\"top\" scope=\"col\">Due Date</th><th valign=\"top\" scope=\"col\">Paid Date</th></tr>";
	    preStatement.setString(1, name);
	    ResultSet res=preStatement.executeQuery();
	   
	    String total=res.getString(1);
	    String installement=res.getString(2);
	    String payable=res.getString(3);
	    String paid=res.getString(4);
	    String due=res.getString(5);
	    String paiddate=res.getString(6);
	    s=s+ "<tr><td>"+ total +"</td><td>"+installement+"</td><td>"+payable+"</td><td>"+paid+"</td><td>"+due+"</td><td>"+paiddate+"</td></tr><tr  align=\"center\"><td align=\"center\" valign=\"top\" colspan=\"2\"><b>Total Payable Amount:</b> </td><td align=\"left\" valign=\"top\" colspan=\"4\">Rs: "+payable+"/</td></tr></tbody></table>";
	    response.getWriter().println(s);
	    preStatement.close();
		conn.close();
	} catch (SQLException e) {
		e.printStackTrace();
	}


	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
